//
//  unittest4.c
//  Dominion
//
//  Eric Hook
//  hooke@onid.orst.edu
//  CS362 Winter 2014
//

#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include "rngs.h"

int seed = 1000;
int k[10] = {adventurer, council_room, feast, gardens, mine, remodel, smithy, village, baron, great_hall};

void testBuyCardUpdatesGamePhaseAndCoinCount() {
    int actualResult=0;
    int result = 0;    
    struct gameState G;
    int origNumBuy = 0;
    int origNumCoins = 0;
    int coinG = G.coins;
    
    printf ("TESTING: buyCard(int supplyPos, struct gameState *state) : unittest2.c.\n");
    
    memset(&G, 23, sizeof(struct gameState));       // clear the game state
    
    result = initializeGame(2, k, seed, &G);
    
    origNumBuy = G.numBuys;
    origNumCoins = G.coins;
    
    G.numBuys = 1;
    coinG = G.coins;
    
    actualResult = buyCard(1, &G);
    
    int cost = getCost(1);

    
    printf("G.phase should be set to 1, result is %d\n", G.phase);
    assert(G.phase == 1);
    printf ("Number of coins should be original (%d) minus cost from getCost (%d) = G->coins  (%d)\n", origNumCoins, cost, G.coins);
    assert(G.coins == (origNumCoins - cost));

    
    printf ("!!! PASS: buyCard(int supplyPos, struct gameState *state) : unittest2.c.\n");
}

int main () {
    testBuyCardUpdatesGamePhaseAndCoinCount();
    return 0;
}